<?php

/**
 * 代理模式
 */

interface Subject
{
    public function say();
    public function run();
}

class RealSubject implements Subject
{
    private $name;
    public function __construct($name)
    {
        $this->name = $name;
    }
    
    public function say()
    {
        echo $this->name."吃饭啦";
    }
    public function run()
    {
        echo $this->name.'跑步啦';
    }
}

class Proxy implements Subject
{
    private $real_subject = NULL;
    public function __construct(RealSubject $real_subject)
    {
        $this->real_subject = $real_subject;
    }
    
    public function say()
    {
        $this->real_subject->say();
    }
    public function run()
    {
        $this->real_subject->run();
    }
}

$subject = new RealSubject("小刘");
$proxy = new Proxy($subject);
$proxy->run();




